<%- if applications.empty? and channels.empty? -%>
  To interact with this account you must first create a new application or a new channel.
<%- else -%>
  <p>These are the ways you can interface with nuntium. This section is updated when you create and modify applications and channels.</p>

  <div style="padding-left:20px">
  <%- if channels.any?{|c| c.kind == 'clickatell'} -%>
    <div><b>Via <%= link_to 'Clickatell', 'http://www.clickatell.com', :target => '_blank' -%></b></div>
    Use <%= link_to 'Http Basic Authentication', 'http://en.wikipedia.org/wiki/Basic_access_authentication', :target => '_blank' -%> with channel name and incoming password.
    <ul>
      <li><span class="url">GET <%= clickatell_url(:account_id => account.name) -%></span>
        create Application Terminated Messages</li>
        <li><span class="url">GET <%= clickatell_ack_url(:account_id => account.id) -%></span
        create Application Terminated Messages</li>
    </ul>
  <%- end -%>

  <%- if channels.any?{|c| c.kind == 'dtac'} -%>
    <div><b>Via <%= link_to 'DTAC', 'http://www.dtac.co.th/', :target => '_blank' -%></b></div>
    Use <%= link_to 'Http Basic Authentication', 'http://en.wikipedia.org/wiki/Basic_access_authentication', :target => '_blank' -%> with channel name and incoming password.
    <ul>
      <li><span class="url">GET <%= dtac_url(:account_id => account.name) -%></span>
        create Application Terminated Messages</li>
    </ul>
  <%- end -%>

  <%- if not applications.empty? -%>
    <div><b>Via HTTP GET</b></div>
    Use <%= link_to 'Http Basic Authentication', 'http://en.wikipedia.org/wiki/Basic_access_authentication', :target => '_blank' -%> with application credentials (use "account/application" as username).

    <ul>
      <%- applications.each do |app| -%>
        <li><span class="url">GET <%= send_ao_url(:account_name => account.name, :application_name => app.name) -%></span>
          create Application Originated Messages from application <%= app.name -%></li>
      <%- end -%>
    </ul>
  <%- end -%>

  <%- if channels.any?{|c| c.kind == 'ipop'} -%>
    <div><b>Via <%= link_to 'I-POP', 'http://www.i-pop.net/', :target => '_blank' -%></b></div>
    <ul>
      <%- channels.select{|c| c.kind == 'ipop'}.each do |channel| -%>
        <li><span class="url">POST <%= ipop_url(:account_id => account.name, :channel_name => channel.name) -%></span>
          create Application Terminated Messages from channel <%= channel.name %></li>
        <li><span class="url">POST <%= ipop_ack_url(:account_id => account.name, :channel_name => channel.name) -%></span>
          receive Delivery Receipts callbacks from channel <%= channel.name %></li>
      <%- end -%>
    </ul>
  <%- end -%>

  <%- if channels.any?{|c| c.kind == 'pop3'} -%>
    <div><b>Via Email</b></div>
    <ul>
      <%- channels.select{|c| c.kind == 'pop3'}.each do |c| -%>
        <li>Send an email to <%= c.user -%>: create Application Terminated Messages</li>
      <%- end -%>
    </ul>
  <%- end -%>

  <%- if channels.any?{|c| c.kind == 'qst_server'} -%>
    <div><b>Via <%= link_to 'QueueStateTransfer', 'http://code.google.com/p/geochat/wiki/QueueStateTransfer', :target => '_blank' -%></b></div>
    <ul>
      <li>Use <span class="url"><%= qst_pull_url(:account_id => account.name)[0 .. -10] %></span> when configuring a QST client using <%= link_to 'Http Basic Authentication', 'http://en.wikipedia.org/wiki/Basic_access_authentication', :target => '_blank' -%> with channel credentials</li>
    </ul>
  <%- end -%>

  <%- unless applications.empty? -%>
    <div><b>Via <%= link_to 'RSS', 'http://en.wikipedia.org/wiki/RSS', :target => '_blank' -%></b></div>
    Use <%= link_to 'Http Basic Authentication', 'http://en.wikipedia.org/wiki/Basic_access_authentication', :target => '_blank' -%> with application credentials (use "account/application" as username).

    <ul>
      <%- applications.each do |app| -%>
        <li><span class="url">POST <%= rss_url(:account_name => account.name, :application_name => app.name) -%></span>
          create Application Originated Messages from application <%= app.name -%></li>
          <li><span class="url">GET <%= create_rss_url(:account_name => account.name, :application_name => app.name) -%></span>
          read Application Terminated Messages to application <%= app.name -%></li>
      <%- end -%>
    </ul>
  <%- end -%>

  <%- if channels.any?{|c| c.kind == 'twitter'} -%>
    <div><b>Via <%= link_to 'Twitter', 'http://www.twitter.com', :target => '_blank' -%></b></div>
    <ul>
      <%- channels.select{|c| c.kind == 'twitter'}.each do |c| -%>
        <li>Send a direct message to <%= c.screen_name -%>: create Application Terminated Messages</li>
      <%- end -%>
    </ul>
  <%- end -%>
  </div>
<%- end -%>
